<?php
@session_start();
$PurviewLevel=3;
$CheckChannelID=1 ;  
$PurviewLevel_Others="";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
?>
<html>
<head>
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>
<body> 
<?php
if ($fid=="" || empty($fid)){
		$fun->popmassage("请选择文章分类","","popback");
		exit();
}

if (strpos("#**#$fiddbadmin2","|||$fid|||")<=0){
		$fun->popmassage("您没有对所选分类的管理权限","","popback");
		exit();
}

if ($postdb[title]=="" || empty($postdb[title])){
		$fun->popmassage("请填写文章标题","","popback");
		exit();
}
//if ($postdb[content]=="" || empty($postdb[content])){
//		$fun->popmassage("请填写文章内容","","popback");
//		exit();
//}
if ($postdb[description]=="" || empty($postdb[description])){
		$fun->popmassage("请填写信息摘要","","popback");
		exit();
}
if ($postdb[yz]==""){$postdb[yz]="0";}
if ($postdb[istop]==""){$postdb[istop]="0";}
if ($postdb[fonttype]==""){$postdb[fonttype]="0";}
if ($postdb[ishome]==""){$postdb[ishome]="0";}
if ($postdb[orderid]==""){$postdb[orderid]=666;}


$postdb[keywords]=$db->mysql_string($postdb[keywords]);
$postdb[title]=$db->mysql_string($postdb[title]);
$postdb[smalltitle]=$db->mysql_string($postdb[smalltitle]);
$truepath=preg_replace("/(.+)\/([^\/]+)\/([^\/]+)/is","\\1",'http://'.$HTTP_HOST);
$postdb[content]=str_replace($truepath,"",$postdb[content]);

$postdb[content]=$db->mysql_string($postdb[content]);
$postdb[author]=$db->mysql_string($postdb[author]);
$postdb[copyfrom]=$db->mysql_string($postdb[copyfrom]);
$postdb[description]=dvhtmlencode($postdb[description]);
$postdb[description]=$db->mysql_string($postdb[description]);
$flvurl=dvhtmlencode($flvurl);
$postdb[iframeurl]=intval($postdb[iframeurl]);
$postdb[hits]=intval($postdb[hits]);

if($action=="saveadd")
{
	$fidDB=$db->get_one(" SELECT * FROM mx_vpp_articleclass  WHERE fid='$fid' ");
	$fname=$fidDB[name];

	$file=$_FILES['picurl'];
	if (!empty($file["name"])){
	$iname = date("YmdHis");
	$picType = explode(".",$_FILES["picurl"]["name"]);
			$picType = $picType[1];		
			$picPath = "../../{$webdb[updir]}/vpparticle/".date("Ym")."/".$iname.".".$picType;
			$img="vpparticle/".date("Ym")."/".$iname.".".$picType;
			movefile("","","../../{$webdb[updir]}/vpparticle/".date("Ym")."/");
			if(move_uploaded_file($_FILES['picurl']['tmp_name'], $picPath))
			{
				chmod($picPath,0777);
			}else{
			/*print_r($_FILES["file"]);*/
			}	
	}
	if (strpos("****".$OtherPurview,'shenhe')<=0 and $Purview!=1){
		$postdb[yz]=0;
		$postdb[levels]=0;
		$postdb[isgood]=0;
		$postdb[istop]=0;
		$postdb[ispl]=0;
		$postdb[ishome]=0;
		$postdb[ishong]=0;
		$postdb[ishot]=0;
	}
	$db->excu("
	INSERT INTO mx_vpp_article 
	(title,smalltitle,keywords,description,content,fid,fname, hits, posttime, orderid,author, copyfrom, titlecolor, fonttype, picurl,flvurl,flvtype,jumpurl, iframeurl,yz, yzer,yzid, yzdate, levels, isgood, istop, ispl, ishome,ishot,createid,createdate) 
	VALUES
('$postdb[title]','$postdb[smalltitle]','$postdb[keywords]','$postdb[description]','$postdb[content]','$fid','$fname','$postdb[hits]','$postdb[posttime]','$postdb[orderid]','$postdb[author]','$postdb[copyfrom]','$postdb[titlecolor]','$postdb[fonttype]','$img','$flvurl','$flvtype','$postdb[jumpurl]','$postdb[iframeurl]','$postdb[yz]','".$_SESSION['mxadmin']['username']."','".$_SESSION['mxadmin']['userid']."','".date("Y-m-d H:i:s")."','$postdb[levels]','$postdb[isgood]','$postdb[istop]','$postdb[ispl]','$postdb[ishome]','$postdb[ishot]','".$_SESSION['mxadmin']['userid']."','".date("Y-m-d H:i:s")."')");

	jump2("操作成功","yx_vpp_article_add.php",2);
	exit();
}

/**
*处理修改文章
**/
if($action=="saveedit")
{

    if ($postdb[aid]=="" || empty($postdb[aid])){
		$fun->popmassage("请选择文章","","popback");
		exit();
    }
	$purmodisql="";
	if ($Purview!=1){
		$purmodisql=" $newsfidsql ";
	}
	$ainfo=$db->getinfo("select * from mx_vpp_article where aid='$postdb[aid]' $purmodisql ");
	if (!is_array($ainfo)){
		$fun->popmassage("请选择要修改的信息","","popback");
		exit();
	}
	$fidDB=$db->get_one(" SELECT * FROM mx_vpp_articleclass  WHERE fid='$fid'");
	$fname=$fidDB[name];
	$file=$_FILES['picurl'];
	if (!empty($file["name"])){
	$iname = date("YmdHis");
	$picType = explode(".",$_FILES["picurl"]["name"]);
			$picType = $picType[1];		
			$picPath = "../../{$webdb[updir]}/vpparticle/".date("Ym")."/".$iname.".".$picType;
			$img="vpparticle/".date("Ym")."/".$iname.".".$picType;
			movefile("","","../../{$webdb[updir]}/vpparticle/".date("Ym")."/");
			if(move_uploaded_file($_FILES['picurl']['tmp_name'], $picPath))
			{
				chmod($picPath,0755);
			}else{
			}	
			@unlink("../../$webdb[updir]/$postdb[oldpicurl]");
	}
	else{
		$img=$postdb[oldpicurl];
	}
	$addsql="";
	if (strpos("****".$OtherPurview,'shenhe')<=0 and $Purview==2){
		$postdb[yz]=0;
	}
		
	if ($Purview==1 or strpos("****".$OtherPurview,'shenhe')>0){
		$addsql=",yz='$postdb[yz]',yzer='".$_SESSION['mxadmin']['username']."',yzid='".$_SESSION['mxadmin']['userid']."',yzdate='".date("Y-m-d H:i:s")."',levels='$postdb[levels]',istop='$postdb[istop]',ispl='$postdb[ispl]',isgood='$postdb[isgood]',ishome='$postdb[ishome]',ishot='$postdb[ishot]'";
	}
	else{
		$addsql=",yz='$postdb[yz]'";
	}

	$db->excu("update mx_vpp_article set title='$postdb[title]',smalltitle='$postdb[smalltitle]',keywords='$postdb[keywords]',price='$postdb[price]',vipprice='$postdb[vipprice]',description='$postdb[description]',content='$postdb[content]',fid='$fid',fname='$fname',posttime='$postdb[posttime]',orderid='$postdb[orderid]',author='$postdb[author]',copyfrom='$postdb[copyfrom]',titlecolor='$postdb[titlecolor]',fonttype='$postdb[fonttype]',picurl='$img',flvurl='$flvurl',flvtype='$flvtype',jumpurl='$postdb[jumpurl]',iframeurl='$postdb[iframeurl]',hits='$postdb[hits]',modiid='".$_SESSION['mxadmin']['userid']."',modidate='".date("Y-m-d H:i:s")."' $addsql where aid='$postdb[aid]' $articlefidsql ");
    $url=url_code($url);
	jump2("操作成功","$url",2);
	exit();
}
?>
</body>
</html>
